<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Register_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }

	function insert_user()
	{		
		$new_user = array(
			'email' => $this->input->post('email'),
			'senha' => $this->input->post('password'),
			'nomeusuario' => $this->input->post('username'),
			'nome' => $this->input->post('name'),
			'sobrenome' => $this->input->post('lastname')            
		);
		
		$query = $this->db->insert('usuarios', $new_user);
		return $query;

	}
	
	function username_check($str)
	{
        $this->db->where('nomeusuario', $str);         
        $query = $this->db->get('usuarios');
        if ($query->num_rows() > 0)
        {
            return true;
        }
        else{
            return false;
        }
	}

	function email_check($str)
	{
        $this->db->where('email', $str);         
        $query = $this->db->get('usuarios');
        if ($query->num_rows() > 0)
        {
            return true;
        }
        else{
            return false;
        }
	}
}

